package servlet;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import usuario.ControladorUsuario;
import usuario.Usuario;


/**
 * Servlet implementation class ServletListarTodosUsuarios
 */
public class ServletListarTodosUsuarios extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletListarTodosUsuarios() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		ControladorUsuario control = new ControladorUsuario();
		
		Collection<Usuario> usuarios = control.listarUsuarios();
		
		HttpSession session = request.getSession();
		session.setAttribute("lista", usuarios);
		response.sendRedirect("ListarTodosUsuarios.jsp");
		
	//	String destino ="listar.jsp";
	//	Collection<Usuario> usuarios = control.listarUsuarios();
	//	request.getSession().setAttribute("lista", usuarios);
		//response.sendRedirect(destino);
	}
		// TODO Auto-generated method stub
	}


